﻿using System.Linq;
using Abp.Authorization;
using Abp.Localization;
using LeadThing.AbpZeroTemplate.Authorization;



namespace LeadThing.AbpZeroTemplate.UserMeetingRefs.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="UserMeetingRefAppPermissions"/> for all permission names.
    /// </summary>
    public class UserMeetingRefAppAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            //在这里配置了UserMeetingRef 的权限。

            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));

            var entityNameModel = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_UserMeetingRefManage)
              ?? pages.CreateChildPermission(AppPermissions.Pages_UserMeetingRefManage, L("Pages_UserMeetingRefManage"));





            var userMeetingRef = entityNameModel.CreateChildPermission(UserMeetingRefAppPermissions.UserMeetingRef, L("UserMeetingRef"));
            userMeetingRef.CreateChildPermission(UserMeetingRefAppPermissions.UserMeetingRef_ComeInToMeetingRoom, L("UserMeetingRef_ComeInToMeetingRoom"));
            //userMeetingRef.CreateChildPermission(UserMeetingRefAppPermissions.UserMeetingRef_CreateUserMeetingRef, L("CreateUserMeetingRef"));
            //userMeetingRef.CreateChildPermission(UserMeetingRefAppPermissions.UserMeetingRef_EditUserMeetingRef, L("EditUserMeetingRef"));
            //userMeetingRef.CreateChildPermission(UserMeetingRefAppPermissions.UserMeetingRef_DeleteUserMeetingRef, L("DeleteUserMeetingRef"));
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, AbpZeroTemplateConsts.LocalizationSourceName);
        }
    }
}